<?php
	class hockydata
	{
		public function LayMonTheoHocKy($hocky_ma = "")
		{
			$sql = "SELECT * FROM hocky ,monhoc , hocky_monhoc WHERE hocky_ma=hk_mh_mahocky and hk_mh_mamonhoc = monhoc_ma and hocky_ma='$hocky_ma'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		public function Them($hocky_ma = "", $hocky_ten = "")
		{
			$sql = "INSERT INTO hocky(hocky_ma, hocky_ten)
					VALUES('$hocky_ma', '$hocky_ten')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function CapNhat($hocky_ma = "", $hocky_ten = "")
		{
			$sql = "UPDATE hocky SET hocky_ten = '$hocky_ten' WHERE hocky_ma = '$hocky_ma'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function Xoa($hocky_ma = "")
		{
			$sql = "DELETE  FROM hocky WHERE hocky_ma = '$hocky_ma'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($hocky_ma = "")
		{
			$sql = "SELECT * FROM hocky WHERE 1";
			
			if($hocky_ma != "")
				$sql .= " AND hocky_ma = '$hocky_ma'";
			
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
		public function DanhSachMonHoc($hocky_ma)
		{
			$sql = " SELECT * FROM `hocky`, `hocky_monhoc`,`monhoc` WHERE hocky_ma = hk_mh_mahocky AND hk_mh_mamonhoc=monhoc_ma ";		
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
	}
?>